import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import { staticRoutes } from './constantRoutes'
import { getMicroApp } from 'vite-plugin-legacy-qiankun'
import pkg from '../../package.json'

const microApp = getMicroApp(pkg.name)

const router = createRouter({
  history: createWebHistory(microApp.__POWERED_BY_QIANKUN__ ? '/storage' : '/'),
  routes: staticRoutes as RouteRecordRaw[],
  // 刷新时，滚动条位置还原
  scrollBehavior: () => ({ left: 0, top: 0 }),
})

export default router
